package testpackage.common.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.junit.Test;

import com.common.utils.DBUtils;

public class TDBUtils {
	
	@Test
	public void find(){
		DBUtils db = DBUtils.getInstance();
		String sql = "select date from my_first";
		List<String[]> list = db.find(sql, 1);
		for(String[] strs:list){
			for(String str:strs){
				System.out.println(str);
			}
		}
	}
	
	@Test
	public void findAll(){
		DBUtils db = DBUtils.getInstance();
		String sql = "select * from my_first";
		List<String[]> list = db.find(sql);
		for(String[] strs:list){
			for(String str:strs){
				System.out.print(str+"\t");
			}
			System.out.println();
		}
	}
	
	@Test
	public void r_inster(){
		DBUtils db = DBUtils.getInstance();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String date = sdf.format(new Date());
		String sql = "insert into my_first values ('"+date.substring(11)+"','"+date+"','来个中文')";
		System.out.println(sql);
		int count = db.update(sql);
		System.out.println("影响了"+count+"条数据");
	}
}
